//
//  AppDelegate.m
//  <7>NSUndoManager
//
//  Created by chen on 16/9/8.
//  Copyright © 2016年 tyrad. All rights reserved.
//

#import "AppDelegate.h"

@interface AppDelegate ()
{
    NSInteger _temperature ;
    
    NSUndoManager *_undoManager ;
}
@property (weak) IBOutlet NSWindow *window;
@end

@implementation AppDelegate

- (instancetype)init
{
    self = [super init];
    if (self) {
        _undoManager = [[NSUndoManager alloc]init];
        
    }
    return self;
}

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    // Insert code here to initialize your application
}

- (void)applicationWillTerminate:(NSNotification *)aNotification {
        
}



//在undo控制器上添加了相反的操作

- (void)makeItHotter{
    
    _temperature = _temperature + 10 ;
    
    [[_undoManager prepareWithInvocationTarget:self] makeItColder];
    
}


- (void)makeItColder{
    _temperature = _temperature - 10 ;
    
    [[_undoManager prepareWithInvocationTarget:self] makeItHotter];
}


@end















